Skip to content

fix(safeguarding): GATE0 case 2 safeguarding state; widen phrasebank selector for PROFESSIONAL - #19

Merged
camlambert2000 merged 3 commits into
mainfrom
staging
May 14, 2026
Merged

fix(safeguarding): GATE0 case 2 safeguarding state; widen phrasebank selector for PROFESSIONAL#19
camlambert2000 merged 3 commits into
mainfrom
staging

Conversation

@camlambert2000

Copy link
Copy Markdown
Collaborator

Summary

  • GATE0 case 2 safeguarding state fix (lib/handlers/crisis.ts:217). Selecting "Under 16 and need protection" now sets safeguardingTriggered: true and safeguardingType: 'UNDER_16' on the transition to CRISIS_UNDER16_LOCATION. Previously the flag was only set at buildUnder16Exit (after the LA prompt), leaving sessions that abandon at the location prompt invisible to safeguarding telemetry.
  • Phrasebank selector widened to accept userType (lib/phrasebank.ts:2390, lib/stateMachine.ts:163, lib/handlers/shared.ts:15). getPhrase and the two phrase() wrappers now accept 'SELF' | 'SUPPORTER' | 'PROFESSIONAL' | null | boolean. Selection rules: 'PROFESSIONAL' looks for __PROFESSIONAL first, falls back to __SUPPORTER, then base; 'SUPPORTER' or true looks for __SUPPORTER then base; everything else returns base. Backwards-compatible — every existing caller still passes session.isSupporter (boolean) and resolves identically to before.
  • Backlog updated to reflect both items.

Pending

__PROFESSIONAL phrasebank entries are not in this PR — they are pending James's language sign-off and will follow in PR #20. Until those entries land, professional users continue to resolve to the __SUPPORTER fallback (same behaviour as before this PR). The selector is in place so PR #20 only needs to add content.

Test plan

  • npm test — 96 / 96 pass locally, including under-16 safeguarding paths and supporter-mode tests.
  • CI green on staging.
  • Manual: confirm GATE0 → option 2 → location prompt → abandon now shows safeguardingTriggered: true in the session payload (app/api/chat/route.ts:352).

🤖 Generated with Claude Code

…sebank selector for PROFESSIONAL variant

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
street-support-va-staging Ready Ready Preview, Comment May 6, 2026 5:09am
streetsupport-platform-va Ready Ready Preview, Comment May 6, 2026 5:09am

Request Review

@james-cross james-cross left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted in error, please disregard.

@camlambert2000

Copy link
Copy Markdown
Collaborator Author

Regression test added per review — Crisis gate option 2 › GATE0 option 2 sets safeguardingTriggered and safeguardingType before LA prompt — placed between the existing "Under 16" and "16-17 Year Olds" describe blocks. 97/97 passing locally.

Separately: noticed npm run check doesn't include jest, so the project rule "run npm run check before every commit" wasn't actually catching test failures. Will raise a small follow-up PR to add jest to the check script. Out of scope for this PR.
Ready for re-review.

@camlambert2000
camlambert2000 requested a review from james-cross May 6, 2026 13:11
@camlambert2000
camlambert2000 merged commit c03d695 into main May 14, 2026
4 checks passed
camlambert2000 added a commit that referenced this pull request May 14, 2026
…r at exit call sites

Prerequisite structural change for PR #20. PR #19 widened the selector
to accept userType but call sites were not yet passing it. Without this
wiring, the __PROFESSIONAL phrasebank entries added in subsequent
commits would be dead code at the moment of merge.

No behavioural change in this commit: __PROFESSIONAL entries do not yet
exist, so the selector falls back to __SUPPORTER as before. Tests pass
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
camlambert2000 added a commit that referenced this pull request May 19, 2026
…ew tidy-ups recorded

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants